Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

merge-anything

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

merge-anything

Merge objects & other types recursively. A simple & small integration.

  • 5.1.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
504K
decreased by-8.25%
Maintainers
1
Weekly downloads
 
Created

What is merge-anything?

The 'merge-anything' npm package is a utility for deep merging objects and arrays. It provides a simple and flexible way to combine multiple objects or arrays into one, handling nested structures and various data types seamlessly.

What are merge-anything's main functionalities?

Deep Merge Objects

This feature allows you to deeply merge two or more objects. Nested properties are merged recursively.

const { merge } = require('merge-anything');
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { b: { d: 3 }, e: 4 };
const result = merge(obj1, obj2);
console.log(result); // { a: 1, b: { c: 2, d: 3 }, e: 4 }

Merge Arrays

This feature allows you to merge arrays, concatenating their elements.

const { merge } = require('merge-anything');
const arr1 = [1, 2, 3];
const arr2 = [4, 5, 6];
const result = merge(arr1, arr2);
console.log(result); // [1, 2, 3, 4, 5, 6]

Custom Merge Functions

This feature allows you to define custom merge functions to handle specific types of data or merge strategies.

const { merge } = require('merge-anything');
const customMerge = (target, source) => Array.isArray(target) ? target.concat(source) : undefined;
const obj1 = { a: [1, 2] };
const obj2 = { a: [3, 4] };
const result = merge({ extensions: [customMerge] }, obj1, obj2);
console.log(result); // { a: [1, 2, 3, 4] }

Other packages similar to merge-anything

Keywords

FAQs

Package last updated on 23 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc